use serde::{Deserialize, Serialize};
use vsse::{content::ContentCollectionItem, SearchConfig};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Q {
    pub(crate) input: String,
    pub(crate) search_config: Option<SearchConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct A {
    pub(crate) input: Option<String>,
    pub(crate) output: Option<Vec<OutputItem>>,
}

#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct OutputItem {
    content: String,
    distance: f32,
    tags: Option<Vec<String>>,
    short: Option<String>,
}

impl OutputItem {
    pub fn from_contentcollection_item(item: ContentCollectionItem) -> Self {
        Self {
            content: item.content.content().to_owned(),
            tags : item.content.inner.tags.clone(),
            short : item.content.inner.short.clone(),
            distance: item.search_result.distance,
        }
    }
}
impl A {
    pub fn new(input: String, output: Vec<OutputItem>) -> Self {
        Self {
            input: Some(input),
            output: Some(output),
        }
    }
    pub fn none() -> Self {
        Self {
            input: None,
            output: None,
        }
    }
}
